// yi yan dao dan lan jie, ha ha
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;

const int N = 1e5, l = 1e6;
int T;
double get_v1(int v0, int a, int s) {return v0 * v0 + 2 * a * s >= 0 ? sqrt(v0 * v0 + 2 * a * s) : 0;}
double get_s(int v1, int v0, int a) {return (v1 * v1 - v0 * v0) / 2 * a;}
int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> T;
    while (T--) {
        bool flag_a = 1, flag_b = 1, flag_c = 1;
        double L, V, s1[N + 3], s2[N + 3], p[N + 3] = {0};
        int n, m, cnt1 = 0, cnt2 = 0, ans1 = 0;
        cin >> n >> m >> L >> V;
        for (int i = 1; i <= n; i++) {
            double d, v, a;
            cin >> d >> v >> a;
            if (a > 0) {
                flag_a = flag_c = 0;
                if (v <= V) {
                    double tmp = get_s(V, v, a);
                    if (d + tmp <= L) s1[++cnt1] = d + tmp;
                }
                else s1[++cnt1] = d;
            } else if (a < 0) {
                flag_a = flag_b = 0;
                if (v > V) {
                    double tmp = get_s(v, V, -a);
                    if (d + tmp <= L) s2[++cnt2] = d + tmp;
                    else ans1++;
                }
            } else {
                flag_b = flag_c = 0;
                if (v > V) ans1++;
            }
        }
        for (int i = 1; i <= m; i++) cin >> p[i];
        sort(s1 + 1, s1 + cnt1 + 1);
        sort(s2 + 1, s2 + cnt2 + 1);
        sort(p + 1, p + m + 1);
        if (flag_a) {
            cout << ans1 << ' ';
            if (ans1) cout << m - 1 << '\n';
            else cout << m << '\n';
            continue;
        }
//        for (int i = 1; i <= cnt1; i++) cout << s1[i] << ' '; cout << '\n';
//        for (int i = 1; i <= cnt2; i++) cout << s2[i] << ' '; cout << '\n';
        int l = 1, r = cnt1;
        while (l < r) {
            int mid = l + r >> 1;
            if (p[m] < s1[mid]) r = mid;
            else l = mid + 1;
        }

        if (cnt1) ans1 += l;
        l = 1, r = cnt2;
        while (l < r) {
            int mid = l + r >> 1;
            if (p[1] < s2[mid]) r = mid;
            else l = mid + 1;
        }
        if (cnt2) ans1 += l;
        cout << ans1 << ' ' << '\n';
    }
    return 0;
}
